<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Tes_asisten extends Authenticated{
	function __construct() {
		parent::__construct();
		$this->load->model('user_model','user');
	}
	
	function soal_pti_b(){
		if($this->session->userdata('nilai_pti_b')>=75){
			redirect(HOME);
		}
		$this->load->view('template/view_header');
		$this->load->view('template/view_menu');
		$this->load->view('tes_asisten/soal_ptib');
		$this->load->view('template/view_footer');
	}
	
	function periksa_pti_b(){
		$arr_jawaban[1]=4;
		$arr_jawaban[2]=4;
		$arr_jawaban[3]=4;
		$arr_jawaban[4]=1;
		$arr_jawaban[5]=1;
		$arr_jawaban[6]=4;
		$arr_jawaban[7]=2;
		$arr_jawaban[8]=1;
		$arr_jawaban[9]=3;
		$arr_jawaban[10]=3;
		$jum_benar = 0;
		for($i=1;$i<11;$i++){
			$name = 'soal_'.$i;
			$pil = $_POST[$name];
			if($pil==$arr_jawaban[$i]){
				$jum_benar++;
			}
		}
		$jum_benar*=10;
		$this->user->nilai_pti_b($this->session->userdata('nim'),$jum_benar);
		redirect(TES.'display_hasil');
	}
	
	function soal_pti_c(){
		if($this->session->userdata('nilai_pti_c')>=75){
			redirect(HOME);
		}
		$this->load->view('template/view_header');
		$this->load->view('template/view_menu');
		$this->load->view('tes_asisten/soal_ptic');
		$this->load->view('template/view_footer');
	}
	
	function periksa_pti_c(){
		$arr_jawaban[1]=3;
		$arr_jawaban[2]=4;
		$arr_jawaban[3]=4;
		$arr_jawaban[4]=2;
		$arr_jawaban[5]=1;
		$arr_jawaban[6]=2;
		$arr_jawaban[7]=2;
		$arr_jawaban[8]=3;
		$arr_jawaban[9]=3;
		$arr_jawaban[10]=4;
		$jum_benar = 0;
		for($i=1;$i<11;$i++){
			$name = 'soal_'.$i;
			$pil = $_POST[$name];
			if($pil==$arr_jawaban[$i]){
				$jum_benar++;
			}
		}
		$jum_benar*=10;
		$this->user->nilai_pti_c($this->session->userdata('nim'),$jum_benar);
		redirect(TES.'display_hasil');
	}
	
	function display_hasil(){
		$this->load->view('template/view_header');
		$this->load->view('template/view_menu');
		$this->load->view('tes_asisten/hasil_tes');
		$this->load->view('template/view_footer');
	}
}
/** End of file */
